Fox's Git Mirrors
Node / rns-mirrors / Reticulum-Go.git / files / examples / pageserver / internal / server / page_stats_bench_test.go
Displaying Raw • Download
examples/pageserver/internal/server/page_stats_bench_test.go 633735d797cc5f5d48cb2e22e8fd7cd743930daf (633735d7) Text, 1.05 KB
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2024-2026 Quad4.io
package server
import "testing"
func BenchmarkRecordPageViewHotPath(b *testing.B) {
r := &Reticulum{pageStats: make(map[string]int64)}
path := "/page/index.mu"
b.ReportAllocs()
b.ResetTimer()
for range b.N {
r.recordPageView(path)
}
}
func BenchmarkRecordPageViewDisabled(b *testing.B) {
r := &Reticulum{pageStatsDisabled: true}
path := "/page/index.mu"
b.ReportAllocs()
b.ResetTimer()
for range b.N {
r.recordPageView(path)
}
}
func BenchmarkFormatPageViewStatsMicron(b *testing.B) {
counts := map[string]int64{
"/page/a.mu": 10,
"/page/b.mu": 20,
"/page/c.mu": 30,
}
b.ReportAllocs()
b.ResetTimer()
for range b.N {
_ = formatPageViewStatsMicron(1_700_000_000, counts)
}
}
func BenchmarkServePageViewStatsCopy(b *testing.B) {
r := &Reticulum{pageStats: map[string]int64{
"/page/a.mu": 1,
"/page/b.mu": 2,
"/page/c.mu": 3,
}}
b.ReportAllocs()
b.ResetTimer()
for range b.N {
_ = r.servePageViewStats("", nil, nil, nil, nil, 0)
}
}
Served by rngit 1.5.2 - Generated in 0.02s